var regtypeid=/(typeid=)([0-9]*)/;
var urlfrom=window.location.href;

var typeid = urlfrom.match(regtypeid).splice("=")[2];
//console.log("获取ID"+typeid);
var regname=/(nameword=)([\%0-9a-zA-Z]*)/;
var typename=decodeURIComponent(urlfrom.match(regname).splice("=")[2]) ;
//获取上级分类
if(/from=zonghe/.test(urlfrom)){
    $(".HeaderSwitcherItem:nth-child(2)").attr("class","HeaderSwitcherItem is_active");
}else if(/from=hangye/.test(urlfrom)){
    $(".HeaderSwitcherItem:nth-child(3)").attr("class","HeaderSwitcherItem is_active");
}else if(/from=xingqu/.test(urlfrom)){
    $(".HeaderSwitcherItem:last-child").attr("class","HeaderSwitcherItem is_active");
}
$(".PinnedTopicFeed .photo_wrapper .photo a").append("<img class='topic_photo_img' src='hyimg/"+typeid+".png'>");
//$(".size_small .photo_wrapper .photo a img").attr("src","http://i1.mopimg.cn/img/tt/2017-03/1086/20170302114043784.jpg");
$(".PinnedTopicFeed .info_wrapper .info").append("<span class='TopicNameSpan TopicName'>"+typename+"</span>");
document.title = "铺路新闻——"+typename;
$(".page_title").html(typename);
$("#maingobackbtn").click(function(){
    history.go(-1);
});
//时间 几天前 几分钟前
function getDateTimeStamp(dateStr){
    dateStr=dateStr.replace(/T/g,' ');
    dateStr=dateStr.replace(/\.[0-9]+/g,'');
    return Date.parse(dateStr.replace(/-/gi,"/"));
}
function getDateDiff(dateTimeStamp){
    var minute = 1000 * 60;
    var hour = minute * 60;
    var day = hour * 24;
    var halfamonth = day * 15;
    var month = day * 30;
    var now = new Date().getTime();
    var diffValue = now - dateTimeStamp;
    if(diffValue < 0){return;}
    var monthC =diffValue/month;
    var weekC =diffValue/(7*day);
    var dayC =diffValue/day;
    var hourC =diffValue/hour;
    var minC =diffValue/minute;
    if(monthC>=1){
        result="" + parseInt(monthC) + "月前";
    }
    else if(weekC>=1){
        result="" + parseInt(weekC) + "周前";
    }
    else if(dayC>=1){
        result=""+ parseInt(dayC) +"天前";
    }
    else if(hourC>=1){
        result=""+ parseInt(hourC) +"小时前";
    }
    else if(minC>=1){
        result=""+ parseInt(minC) +"分钟前";
    }else
        result="刚刚";
    return result;
}
//获取图片的展示宽度

//
function showImg( url,imgid ) {
    //var imgid = Math.random(),
    frameid = 'frameimg' + imgid;
    window['iframeimg'+imgid] = '<img id="iframeimg"'+imgid+' src=\''+url+'\' style="width:100%;display:none;"/>';
    //var newimg='<iframe id="'+frameid+'" src="javascript:parent[\'iframeimg'+imgid+'\'];" frameBorder="0" scrolling="no" width="100%"></iframe>';
    var newimg='<iframe id="'+frameid+'" src="javascript:parent[\'iframeimg'+imgid+'\'];" style="background:url('+url+');background-size:100%;" frameBorder="0" scrolling="no" width="100%"></iframe>';
    return newimg;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var currentIndex=1; //起始页数
var pageSize=10;//一页显示几条新闻
//var newsnum=0;//第几条新闻
var readyover=0;//控制页面滚动 1可以滚动加载 0不可以
var isclick=0;//控制按钮点击状态 0当前没有正在点击的按钮 1有点击的按钮
var p1=0;
var current=0;
var keywordcount=0;//屏蔽关键词个数
var urlcount=0;//屏蔽网址个数
var newscount=0;//屏蔽新闻个数
var newstitle={};//用新闻ID 获取新闻标题



$().ready(function(){

    if($.cookie("newsid")&&/\d/.test($.cookie("newsid"))){ //定位操作
        //console.log($.cookie("newsid"));
        document.getElementsByClassName("HomeMainFeed")[0].removeChild(document.getElementsByClassName("HomeMainFeed")[0].firstChild);
        $(".newsbox").remove();
        current=parseFloat($.cookie("currentIndex"));
        currentIndex=current;
        var allpagenum=parseFloat($.cookie("currentIndex"))*parseFloat(pageSize);//一共有多少条新闻
        //console.log(allpagenum);
        aj2(1,allpagenum);
        var toheight=parseFloat($.cookie("scrollTop"));
        var thisid=$.cookie("newsid");
        var t=parseFloat($.cookie("totop"));
        //console.log(t);
        //console.log(toheight);
        $(window).scrollTop(t);
        $(".HomeMainFeed").scrollTop(t);
        document.body.scrollTop=t;
        readyover=1;
        currentIndex=current;//更改以后加载的页码
    }else{
        //console.log("判断条件执行");
        readyover=1;
        aj(currentIndex,pageSize);
    }
});

//页面滚动
var t=0,p=0; //t保存上一次的滚动距离 p保存当前的滚动距离
//$(".wrapper.home_feed").scroll(function(){
$(window).scroll(function(){
    var mainheight=$(".home_feed").height();
    var windowheight=$(window).height();
    var chajuli=$(".home_feed").offset().top - $(window).scrollTop();
    var scrollheight=$(window).scrollTop();
    var cz=windowheight-mainheight+5;
    if(readyover===1&&chajuli<cz){
        readyover=0;
        //console.log("第几页的新闻？："+currentIndex);
        currentIndex++;
        aj(currentIndex,pageSize);
    }
});
var ajrunning="no";
function aj(currentIndex,pageSize){
    ajrunning="yes";
    isclick=0;
    $.ajax({
        type:"get",
        datatype:"json",
        url:"http://42.62.66.198:9001/api/pulunews/GetpageDataByTypeId0?typeId="+typeid+"&currentIndex="+currentIndex+"&pageSize="+pageSize+"&userId="+id,
        success:function(data){
            //console.log(data);
            if(data.Data==""){
                $("#waiting").css("display","none");
                $("#nonews").css("display","block");
            }
            else{
                var newdata=data.Data.replace(/790x600.jpg/g,"");
                var oneimgurl;//保存一张图片
                data.Data=JSON.parse(newdata).Datas;
                console.log(data.Data);
                if(data.Data.length<10){
                    $("#waiting").css("display","none");
                    $("#nonews").css("display","block");
                }
                var num=0;
                //所有要添加的字符串
                var allhtmlword="";
                for(var i=0;i<data.Data.length;i++){
                    //console.log("isclick",isclick);
                    num++;
                    //截取时间
                    var tim="";
                    if(data.Data[i].published_date){
                        tim=getDateDiff(getDateTimeStamp(data.Data[i].published_date));
                    };
                    //if(data.Data[i].title.length>20){
                    //    data.Data[i].title=data.Data[i].title.substr(0,20)+"...";
                    //};
                    //用新闻的ID 获取新闻的标题
                    if(newstitle[data.Data[i].id]){
                        //已经保存了新闻标题
                    }else{
                        //保存新闻标题
                        newstitle[data.Data[i].id]=data.Data[i].title;
                    }

                    if(data.Data[i].thumb){
                        var iframeimg=showImg(data.Data[i].thumb,data.Data[i].id);
                        allhtmlword+="<div class='newsbox' id='"+data.Data[i].id+"'><div class='tpl-2' onclick='hrefto(this)' data-title='"+data.Data[i].title+"'data-pagenum='"+currentIndex+"'  data-id='"+data.Data[i].id+"' data-url='"+data.Data[i].url+"'><a><div class='clr'><div class='info-content rt'><div class='text-content' ><h2><p>"+data.Data[i].title+"</p></h2></div><div class='news-from'><span class='src-net'>"+data.Data[i].sitename+"·"+tim+"</span><span class='sendit rt' onclick='shareit(this)' data-nid='"+data.Data[i].id+"'><img src='../img/newsshare2.png' data-nid='"+data.Data[i].id+"'></span><span class='src-delet rt overflow' onclick='deleteitfun(this)' data-url='"+data.Data[i].host+","+data.Data[i].sitename+"' id='new"+data.Data[i].id+"'><img src='../img/newsdel2.png'></span></div></div><div class='pic-content'>"+iframeimg+"</div></div></a></div></div>";
                    }else if(!data.Data[i].thumb){
                        allhtmlword+="<div class='newsbox' id='"+data.Data[i].id+"'><div class='tpl-3' data-id='"+data.Data[i].id+"' onclick='hrefto(this)' data-title='"+data.Data[i].title+"' data-url='"+data.Data[i].url+"' data-pagenum='"+currentIndex+"'><a><div class='text-content'><h2><p>"+data.Data[i].title+"</p></h2></div><div class='news-from'><span class='src-net'>"+data.Data[i].sitename+"·"+tim+"</span><span class='sendit rt' onclick='shareit(this)' data-nid='"+data.Data[i].id+"'><img src='../img/newsshare2.png' data-nid='"+data.Data[i].id+"'></span><span class='src-delet rt overflow' id='new"+data.Data[i].id+"' onclick='deleteitfun(this)' data-url='"+data.Data[i].host+","+data.Data[i].sitename+"'><img src='../img/newsdel2.png'></span></div></a></div></div>";
                    }
                    if(num===data.Data.length){
                        $(".HomeMainFeed").append(allhtmlword);
                        $("iframe body").css("padding","0");
                        ajrunning="no";//加载完成
                        isclick=0;
                        //console.log("所有数据加载完成");
                    }
                }
                readyover=1;
            }
        }
    });
}
function aj2(currentIndex,pageSize){
    //console.log("当前页码："+currentIndex);
    //console.log(pageSize);
    //alert("加载所有");
    ajrunning="yes";
    isclick=0;
    var ajaxnum=0;//加载了几条数据
    $.ajax({
        type:"get",
        datatype:"json",
        url:"http://42.62.66.198:9001/api/pulunews/GetpageDataByTypeId0?typeId="+typeid+"&currentIndex="+currentIndex+"&pageSize="+pageSize+"&userId="+id,
        success:function(data){
            //console.log(data);
            $(".newsbox").remove();
            if(data.Data==""){
                //console.log("没有数据了");
                $("#waiting").css("display","none");
                $("#nonews").css("display","block");
                isclick=0;
            }else{
                data.Data=JSON.parse(data.Data).Datas;
                //所有要添加的字符串
                var allhtmlword="";
                for(var i=0;i<data.Data.length;i++){
                    ajaxnum++;//加载了几条数据
                    //截取时间
                    //var tim=data.Data[i].published_date.match(/([0-9\-]+)/)[0];
                    var tim="";
                    if(data.Data[i].published_date){
                        tim=getDateDiff(getDateTimeStamp(data.Data[i].published_date));
                    };
                    if(data.Data[i].title.length>20){
                        data.Data[i].title=data.Data[i].title.substr(0,20)+"...";
                    };
                    if(data.Data[i].thumb){
                        var iframeimg=showImg(data.Data[i].thumb,data.Data[i].id);
                        allhtmlword+="<div class='newsbox' id='"+data.Data[i].id+"'><div class='tpl-2' onclick='hrefto(this)' data-title='"+data.Data[i].title+"'data-pagenum='"+currentIndex+"'  data-id='"+data.Data[i].id+"' data-url='"+data.Data[i].url+"'><a><div class='clr'><div class='info-content rt'><div class='text-content' ><h2><p>"+data.Data[i].title+"</p></h2></div><div class='news-from'><span class='src-net'>"+data.Data[i].sitename+"·"+tim+"</span><span class='sendit rt' onclick='shareit(this)' data-nid='"+data.Data[i].id+"'><img src='../img/newsshare2.png' data-nid='"+data.Data[i].id+"'></span><span class='src-delet rt overflow' onclick='deleteitfun(this)' data-url='"+data.Data[i].host+","+data.Data[i].sitename+"' id='new"+data.Data[i].id+"'><img src='../img/newsdel2.png'></span></div></div><div class='pic-content'>"+iframeimg+"</div></div></a></div></div>";
                    }else if(!data.Data[i].thumb){
                        allhtmlword+="<div class='newsbox' id='"+data.Data[i].id+"'><div class='tpl-3' data-id='"+data.Data[i].id+"' onclick='hrefto(this)' data-title='"+data.Data[i].title+"' data-url='"+data.Data[i].url+"' data-pagenum='"+currentIndex+"'><a><div class='text-content'><h2><p>"+data.Data[i].title+"</p></h2></div><div class='news-from'><span class='src-net'>"+data.Data[i].sitename+"·"+tim+"</span><span class='sendit rt' onclick='shareit(this)' data-nid='"+data.Data[i].id+"'><img src='../img/newsshare2.png' data-nid='"+data.Data[i].id+"'></span><span class='src-delet rt overflow' id='new"+data.Data[i].id+"' onclick='deleteitfun(this)' data-url='"+data.Data[i].host+","+data.Data[i].sitename+"'><img src='../img/newsdel2.png'></span></div></a></div></div>";
                    }
                    //console.log(ajaxnum);
                    if(ajaxnum===pageSize){
                        $(".HomeMainFeed").append(allhtmlword);
                        //alert("开始页面定位");
                        var t=parseFloat($.cookie("totop"));
                        //t=$.cookie("scrollTop");
                        //alert("保存的高度："+$.cookie("totop"));
                        //console.log(t);
                        $(window).scrollTop(t);
                        //$(".HomeMainFeed").scrollTop(t);
                        $(".home_feed").scrollTop(t);
                        document.body.scrollTop=t;
                        ajrunning="no";//加载完成
                    }
                }
            }
        }
    });
}
//跳转 历史定位 新闻详情页
function hrefto(d){
    $.cookie("currentIndex","");
    $.cookie("scrollTop","");
    $.cookie("newsid","");
    $.cookie("totop","");
    var urlinfo=d.dataset.url;
    var nthisid=d.dataset.id;
    //var t = $(".home_feed").scrollTop();
    var t = $(window).scrollTop();
    $.cookie("newsid",d.dataset.id);
    $.cookie("totop",t);
    var currentIndex= parseFloat(d.dataset.pagenum);
    $.cookie("currentIndex",currentIndex);
    //var scrollTop=$(".home_feed").scrollTop();
    var scrollTop=$(window).scrollTop();
    $.cookie("scrollTop",scrollTop);
    $.cookie("newstitle",d.dataset.title);
    $.cookie("newsurl",urlinfo);
    $.ajax({
        type:"post",
        datatype:"json",
        url:"http://42.62.66.198:9001/api/PuluNews/AddCount",
        data:{"newsId": d.dataset.id},
        success:function(d){
            //location.href=urlinfo;
            location.href="weixin/newsdetail.html?newsid="+$.cookie("newsid")+"&fromuser="+id;
        }
    })
    //$.ajax({
    //    type:"post",
    //    datatype:"json",
    //    url:"http://42.62.66.198:9001/api/PuluNews/AddCount",
    //    data:{"newsId": d.dataset.id},
    //    success:function(d){
    //        $("#newsiframe").attr("src",urlinfo);
    //        $("#seenews").css("display","block");
    //        $("#page_wrapper").css("display","none");
    //        $(".wrapper.home_feed").css("overflow","hidden");
    //        //$("body").css("overflow","hidden");
    //        document.getElementById("iframesharebtn").dataset.newsid= nthisid;
    //    }
    //})
}
//关闭新闻详情页
$("#iframegoback").click(function(){
    $("#newsiframe").attr("src","");
    $("#seenews").css("display","none");
    $("#page_wrapper").css("display","block");
    //$("body").css("overflow","auto");
    $(".wrapper.home_feed").css("overflow","auto");
});
//详情页面分享操作
$("#iframesharebtn").click(function(e){
    //console.log(cansend);
    //console.log(newstitle);
    var newsid= e.target.dataset.newsid;
    $("#sharetitleword div").html(newstitle[newsid]);
    $("#seenews").css("display","none");
    $("#shareword").css("display","block");
    //转发确定按钮
    if(cansend==1){
        //console.log(cansend);
        sendcommentbtn.onclick=function(){
            cansend=0;
            sendcommentbtn.disabled=true;
            if(commentinput.value){
                if(commentinput.value.match(/^\s+$/g)){
                    $("#sharewaiting").css("display","block");
                    $.ajax({
                        type:"post",
                        datatype:"json",
                        url:addshareurl,
                        data:{"contentid":newsid,"userid":id,"fromuser":"","des":"","contenttype":1},
                        success:function(data){
                            //console.log(data);
                            commentinput.value="";
                            shareword.style.display="none";
                            $("#sharewaiting").css("display","none");
                            $("#seenews").css("display","block");
                            $("#collectword").css("display","block");
                            setTimeout(function(){
                                $("#collectword").css("display","none");
                            },1000);
                            clearTimeout();
                            cansend=1;
                            sendcommentbtn.disabled=false;
                        }
                    })
                }else{
                    $.ajax({
                        type:"post",
                        datatype:"json",
                        url:addshareurl,
                        data:{"contentid":newsid,"userid":id,"fromuser":"","des":commentinput.value,"contenttype":1},
                        success:function(data){
                            //console.log(data);
                            commentinput.value="";
                            shareword.style.display="none";
                            $("#seenews").css("display","block");
                            $("#collectword").css("display","block");
                            setTimeout(function(){
                                $("#collectword").css("display","none");
                            },1500);
                            clearTimeout();
                            cansend=1;
                            sendcommentbtn.disabled=false;
                        }
                    })
                }
            }else{
                $.ajax({
                    type:"post",
                    datatype:"json",
                    url:addshareurl,
                    data:{"contentid":newsid,"userid":id,"fromuser":"","des":"","contenttype":1},
                    success:function(data){
                        //console.log(data);
                        commentinput.value="";
                        shareword.style.display="none";
                        $("#collectword").css("display","block");
                        $("#seenews").css("display","block");
                        setTimeout(function(){
                            $("#collectword").css("display","none");
                        },1500);
                        clearTimeout();
                        cansend=1;
                        sendcommentbtn.disabled=false;
                    }
                })
            }
        };
    }
    //取消
    cancelbtn.onclick=function(){
        commentinput.value="";
        $("#seenews").css("display","block");
        shareword.style.display="none";
    }
});
//判断屏蔽个数
function maxnum(){
    //newscount= d.Data.newsCount;//已经屏蔽的新闻个数
    //urlcount= d.Data.siteCount;//已经屏蔽的网址个数
    //keywordcount= d.Data.keyWordsCount;//已经屏蔽的关键词个数
    if(newscount>=100){
        $("#deleteit").html("屏蔽新闻已达上限");
    }else{
        $("#deleteit").html("屏蔽该新闻");
    };
    if(urlcount>=100){
        $("#deleteurl").html("屏蔽网站已达上限");
    }else{
        $("#deleteurl").html("屏蔽该网站");
    };
    if(keywordcount>=100){
        $("#inputkey").attr("placeholder","屏蔽关键词已达上限");
        $("#inputkey").attr({"disabled":"disabled"});
        $("#sendword").addClass("maxnum");
    }else{
        $("#inputkey").attr("placeholder","");
        $("#inputkey").removeAttr("disabled");
        $("#sendword").removeClass("maxnum");
    }
}
//屏蔽操作
var spanx;
var urlinfo;
function deleteitfun(spanx){
    if ( spanx && spanx.stopPropagation ) {
        spanx.stopPropagation();
    } else {
        window.event.cancelBubble = true;
    }
    thisid=spanx.id.match(/([0-9]+)/)[0];
    //console.log("屏蔽的ID："+thisid);
    urlinfo=spanx.dataset.url;
    //console.log(urlinfo);
    //maxnum();
    <!--模态框淡入淡出-->
    var overflowlist=document.getElementsByClassName("overflow");
    var modalbg=document.getElementsByClassName("modal_bg")[0];
    var modal=document.getElementsByClassName("action_menu_container")[0];
    var cancel=document.getElementsByClassName("cancel")[0];
    var timer;
    $(".modal_bg").css("display","block");
    $(".action_menu_container").css("display","block");
    $("#inputkey").val("");//清空输入框上次数据
    cancel.onclick=function(){
        if(modalbg.style.display=="block"&&modal.style.display=="block"){
            modalbg.className+=' animate_out';
            modal.className+=' animate_out';
        }
        timer=setTimeout(changeclass,100);
    };
    function changeclass(){
        modalbg.className='modal_bg';
        modal.className='action_menu_container';
        clearTimeout();
        timer=null;
        changedisplay();
    }
    function changedisplay(){
        modalbg.style.display="none";
        modal.style.display="none";
    }
    //////////////////////////////////////////////////////////////////////////////
    //document.getElementById(spanx.id).
    //屏蔽该新闻
    $("#deleteit").click(function(){
        //console.log("ajrunning",ajrunning);
        //console.log("isclick",isclick);
        if(isclick===0&&newscount<100){
            isclick=1;
            if(modalbg.style.display=="block"&&modal.style.display=="block"){
                modalbg.className+=' animate_out';
                modal.className+=' animate_out';
            }
            timer=setTimeout(changeclass,100);
            //console.log("屏蔽该新闻内部id："+thisid);
            $.ajax({
                type:"post",
                datatype:"json",
                url:"http://42.62.66.198:9001/api/PuluShield/Addpulu_shield",
                data:{"userId":id,"content":thisid,"shieldtype":3},
                success:function(data){
                    //console.log(data);
                    //console.log(thisid);
                    if(ajrunning==="no"){//如果加载完成
                        $("div#"+thisid).remove();
                        isclick=0;
                        newscount++;
                        thisid=null;
                        var newsboxlen=document.getElementsByClassName("newsbox").length;
                        //页面剩余新闻小于等于5个
                        if(newsboxlen<=5){
                            isclick=0;
                            currentIndex++;
                            aj(currentIndex,pageSize);
                        }
                    }
                }
            })
        }

    });
    //屏蔽该网址
    $("#deleteurl").click(function(e){
        if(isclick===0&&urlcount<100){
            isclick=1;
            if(modalbg.style.display=="block"&&modal.style.display=="block"){
                modalbg.className+=' animate_out';
                modal.className+=' animate_out';
            }
            timer=setTimeout(changeclass,100);
            //console.log("屏蔽网站内部id："+thisid);
            $.ajax({
                type:"post",
                datatype:"json",
                url:"http://42.62.66.198:9001/api/PuluShield/Addpulu_shield",
                data:{"userId":id,"content":urlinfo,"shieldtype":2},
                success:function(da){
                    urlinfo=null;
                    $.cookie("currentIndex","");
                    $.cookie("scrollTop","");
                    $.cookie("newsid","");
                    $.cookie("totop","");
                    currentIndex=1;
                    pageSize=10;
                    $(".HomeMainFeed div").remove();
                    aj(currentIndex,pageSize);
                    ////console.log(da);
                    ////console.log(thisid);
                    //if(ajrunning==="no"){
                    //    $("div#"+thisid).remove();
                    //    isclick=0;
                    //    newscount++;
                    //    thisid=null;
                    //
                    //    var newsboxlen=document.getElementsByClassName("newsbox").length;
                    //    //页面剩余新闻小于等于5个
                    //    if(newsboxlen<=5){
                    //        isclick=0;
                    //        currentIndex++;
                    //        aj(currentIndex,pageSize);
                    //    }
                    //}
                }
            })
        }
    });
    //屏蔽关键词
    $("#sendword").click(function(){
        //alert("点击操作");
        if(isclick===0&&keywordcount<100){
            if($("#inputkey").val()&&$("#inputkey").val().length>0&&!$("#inputkey").val().match(/\s/)){
                isclick=1;
                $.ajax({
                    type:"post",
                    datatype:"json",
                    url:"http://42.62.66.198:9001/api/PuluShield/Addpulu_shield",
                    data:{"userId":id,"content":$("#inputkey").val(),"shieldtype":1},
                    success:function(da){
                        //console.log("屏蔽关键词");
                        //console.log(da);
                        $("#inputkey").val("");
                        timer=setTimeout(changeclass,100);
                        isclick=0;
                        keywordcount++;
                    }
                })
            }
        }

    });
}
//分享
function shareit(e){
    if ( e && e.stopPropagation ) {
        e.stopPropagation();
    } else {
        window.event.cancelBubble = true;
    }
    //"转发操作");
    //console.log(cansend);
    $(".HeaderSwitcher.ReadSwitcher.SubHeader").css("display","block");
    //转发
    $.cookie("sharenewsid",e.dataset.nid);
    location.href="sendsharepage.html?type=1";
    //var thisid= e.dataset.nid;
    //var shareword=document.getElementById("shareword");
    //var cancelbtn=document.getElementById("cancelbtn");
    //var commentinput=document.getElementById("commentinput");
    //var sendcommentbtn=document.getElementById("sendcommentbtn");
    ////转发显示标题文字
    //$("#sharetitleword div").html(e.parentNode.parentNode.parentNode.firstChild.firstChild.innerHTML);
    //shareword.style.display="block";
    ////转发确定按钮
    //if(cansend==1){
    //    //console.log(cansend);
    //    sendcommentbtn.onclick=function(){
    //        cansend=0;
    //        sendcommentbtn.disabled=true;
    //        if(commentinput.value){
    //            if(commentinput.value.match(/^\s+$/g)){
    //                $.ajax({
    //                    type:"post",
    //                    datatype:"json",
    //                    url:addshareurl,
    //                    data:{"contentid":thisid,"userid":id,"fromuser":"","des":"","contenttype":1},
    //                    success:function(data){
    //                        //console.log(data);
    //                        commentinput.value="";
    //                        shareword.style.display="none";
    //                        $("#collectword").css("display","block");
    //                        setTimeout(function(){
    //                            $("#collectword").css("display","none");
    //                        },1000);
    //                        clearTimeout();
    //                        cansend=1;
    //                        sendcommentbtn.disabled=false;
    //                    }
    //                })
    //            }else{
    //                $.ajax({
    //                    type:"post",
    //                    datatype:"json",
    //                    url:addshareurl,
    //                    data:{"contentid":thisid,"userid":id,"fromuser":"","des":commentinput.value,"contenttype":1},
    //                    success:function(data){
    //                        //console.log(data);
    //                        commentinput.value="";
    //                        shareword.style.display="none";
    //                        $("#collectword").css("display","block");
    //                        setTimeout(function(){
    //                            $("#collectword").css("display","none");
    //                        },1500);
    //                        clearTimeout();
    //                        cansend=1;
    //                        sendcommentbtn.disabled=false;
    //                    }
    //                })
    //            }
    //        }else{
    //            $.ajax({
    //                type:"post",
    //                datatype:"json",
    //                url:addshareurl,
    //                data:{"contentid":thisid,"userid":id,"fromuser":"","des":"","contenttype":1},
    //                success:function(data){
    //                    //console.log(data);
    //                    commentinput.value="";
    //                    shareword.style.display="none";
    //                    $("#collectword").css("display","block");
    //                    setTimeout(function(){
    //                        $("#collectword").css("display","none");
    //                    },1500);
    //                    clearTimeout();
    //                    cansend=1;
    //                    sendcommentbtn.disabled=false;
    //                }
    //            })
    //        }
    //    };
    //}
    //取消
    cancelbtn.onclick=function(){
        commentinput.value="";
        shareword.style.display="none";
    }
}
//新改写转发
var cansend=1;// 1可以转发 0不可以转发
//$("#page_wrapper").delegate(".sendit","click",function(e){
//
//});
//控制屏蔽关键词按钮样式变化
$(function(){
    $("#sendword").bind('input propertychange', function() {
        //$("#sendword").css("init");
        $('#sendword').attr('class','init');
        document.getElementById("sendword").className="init";
    });
});